package beegoRoute

import (
	"github.com/beego/beego/v2/server/web"
	"net/http"
)

type Route struct {
	path         string
	handleFunMap map[string]web.HandleFunc //http方法名
}

func NewRoute(path string) *Route {
	handleFun := make(map[string]web.HandleFunc)
	return &Route{path, handleFun}
}

func (r *Route) SetHandleFun(method string, fun web.HandleFunc) *Route {
	r.handleFunMap[method] = fun
	return r
}
func (r *Route) SetFullHandleFun(fun web.HandleFunc) *Route {
	r.handleFunMap[http.MethodPost] = fun
	r.handleFunMap[http.MethodGet] = fun
	return r
}

func (r *Route) SetGetHandleFun(fun web.HandleFunc) *Route {
	r.handleFunMap[http.MethodGet] = fun
	return r
}
func (r *Route) SetPostHandleFun(fun web.HandleFunc) *Route {
	r.handleFunMap[http.MethodPost] = fun
	return r
}
func (r *Route) GetPath() string {
	return r.path
}
func (r *Route) GetHandleMap() map[string]web.HandleFunc {
	return r.handleFunMap
}
